<!-- ./idFieldRender.vue 文件 -->
<template>
    <div>
        <!-- 自定义 -->
        <span>
            <el-text class="ml15">
                {{ state.value }}
            </el-text>
        </span>

        
    </div>
</template>

<script setup lang="ts">
import { TableColumnCtx, ElInput } from 'element-plus'
import { reactive, ref, nextTick } from 'vue';
import { updateOrderNumApi } from '/@/api/frontend/order/merge'
import { ElNotification } from 'element-plus'

// 自定义

const inputRef = ref()

const buttonRef = ref();
const popoverRef = ref();

// BuildAdmin将自动为此组件传递五个Props
interface Props {
    renderValue: any // 单元格值
    renderRow: TableRow // 当前行数据
    renderField: TableColumn // 当前列数据
    renderColumn: TableColumnCtx<TableRow> // 当前列上下文数据
    renderIndex: number // 当前行号
}
const props = defineProps<Props>()

const state = reactive({
    num: null,
    value: props.renderValue,
    newValue: -1,
    loading: false,
    name: '',
    hasSelection: true,
    dropdownList: [],
    prop: '',
    visible: false
})

const hide = () => {
    popoverRef.value.hide();
};

const msg = () => {
    ElNotification({
        message: '当前订单状态禁止修改数量',
        type: 'error',
    });
}


const save = () => {
    if(state.loading == true) return;
    if(state.num == null || state.num <= 0){
        ElNotification({
            message: '请输入数量',
            type: 'error',
        });
        return;
    }
    state.loading = true;
    updateOrderNumApi({id:props.renderRow.id, num: state.num}).then((e) => {
        state.loading = false;
        hide();
        if(e.code == 1){
            state.value = state.num;
            props.renderRow.total_price_text = e.data.total_price_text;
            
        }else{
            
        }
        
    }).catch((err) => {
        state.loading = false;
        hide();
        console.log(err)
    })
}



</script>

<style scoped lang="scss">
// 自定义
.pointer{
    cursor: pointer;
    user-select: none;
}
.agency-fee-input{
    width: 150px;
}
.info-tag{
    cursor: no-drop;
}

:deep(.el-tag){
    font-size: 14px;
    padding: 14px 9px;
}
</style>